package com.mt.roll.wms.controller;

import com.mt.roll.core.base.BaseController;
import com.mt.roll.core.constants.CommonConstant;
import com.mt.roll.core.params.IdParam;
import com.mt.roll.core.validator.groups.AddGroup;
import com.mt.roll.core.validator.groups.PageGroup;
import com.mt.roll.core.validator.groups.UpdateGroup;
import com.mt.roll.core.vo.IdVo;
import com.mt.roll.core.vo.PageVo;
import com.mt.roll.core.vo.R;
import com.mt.roll.wms.params.ProcessLocationParam;
import com.mt.roll.wms.params.ProcessLocationQueryParam;
import com.mt.roll.wms.params.SubidWorkorderParam;
import com.mt.roll.wms.params.SubidWorkorderQueryParam;
import com.mt.roll.wms.service.ProcessLocationService;
import com.mt.roll.wms.service.SubidWorkorderService;
import com.mt.roll.wms.vo.ProcessLocationVo;
import com.mt.roll.wms.vo.SubidWorkorderVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.groups.Default;

/**
 * @auther yanyang
 * @date 2022/3/10 15:45
 */

@RestController
@RequestMapping(CommonConstant.API_MODULE_WMS + "subidworkorder")
@Slf4j
@Api(value = "绑定基板工单信息", tags = "基板工单信息", hidden = false)
public class SubidWorkorderController extends BaseController {

    @Autowired
    private SubidWorkorderService subidWorkorderService;

    @PostMapping(value = "page")
    @ApiOperation(value = "基板工单信息")
    private R<PageVo<SubidWorkorderVo>> page(@Validated({PageGroup.class, Default.class}) @RequestBody SubidWorkorderQueryParam subidWorkorderQueryParam) {
        return subidWorkorderService.page(subidWorkorderQueryParam);
    }

    @PostMapping(value = "getById")
    @ApiOperation(value = "获取基板工单信息")
    private R<SubidWorkorderVo> getById(@Validated @RequestBody IdParam idParam) {
        return subidWorkorderService.getById(idParam);
    }

    @PostMapping(value = "add")
    @ApiOperation(value = "手动绑定基板工单")
    private R<IdVo> add(@Validated({AddGroup.class, Default.class}) @RequestBody SubidWorkorderParam subidWorkorderParam) {
        return subidWorkorderService.add(subidWorkorderParam);
    }

    @PostMapping(value = "update")
    @ApiOperation(value = "更新基板工单信息")
    private R<IdVo> update(@Validated({UpdateGroup.class, Default.class}) @RequestBody SubidWorkorderParam  subidWorkorderParam) {
        return subidWorkorderService.update(subidWorkorderParam);
    }

    @PostMapping(value = "delete")
    @ApiOperation(value = "删除基板工单信息")
    private R<IdVo> delete(@Validated @RequestBody IdParam idParam) {
        return subidWorkorderService.delete(idParam);
    }

}
